package com.cet.designpatterns.strategy;

/**
 * @program: algorithm
 * @description: 相当于环境类
 * @author: 陈恩涛
 * @create: 2021-09-28 21:42
 **/
public abstract class Duck {

    protected FlyBehavior flyBehavior;

    public Duck(){
    }

    /**
     * 飞翔行为切换
     * @param flyBehavior
     */
    public void setFlyBehavior(FlyBehavior flyBehavior) {
        this.flyBehavior = flyBehavior;
    }

    public abstract void display();

    public void fly() {
        if (flyBehavior != null) {
            flyBehavior.fly();
        }
    }
}
